package com.atung.dao;

import org.apache.ibatis.annotations.InsertProvider;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import com.atung.model.BusRoutApplication;
import com.atung.provider.BusRoutApplicationProvider;

@Mapper
public interface BusRoutApplicationDAO {

	/**
	 * 查询申请信息
	 * @param openId
	 * @param departlId
	 * @param destination_id
	 * @return
	 */
	@Select("select * from bus_rout_application where application_open_id=#{openId} and departl_id=#{departlId}  and destination_id=#{destinationId}")
	BusRoutApplication selectRoutApplicationByOpenidAndDepartlIdAndDestinationId(@Param("openId")String openId,
			@Param("departlId") Long departlId,@Param("destinationId")Long destinationId);
	
	
	/**
	 * 获取开通人数
	 * @param departlId
	 * @param destinationId
	 * @return
	 */
	@Select("select count(id) from bus_rout_application where  departl_id=#{departlId}  and destination_id=#{destinationId}")
	Integer countRoutApplicationByDepartlIdAndDestinationId(@Param("departlId") Long departlId,@Param("destinationId")Long destinationId);
	/**
	 * 新增申请信息
	 * @param busRoutApplication
	 * @return
	 */
	@InsertProvider(type=BusRoutApplicationProvider.class,method="saveBusRoutApplication")
	Boolean saveRoutApplication(BusRoutApplication busRoutApplication);
}
